// const  baseURL = 'http://172.16.24.59:8092';
const  baseURL = 'http://twapi.huoxingqianli.com';

export const myRequest = (options) => {
	return new Promise((resolve, reject) => {
		if(!options.noLoading)uni.showLoading({})
		uni.request({
			url: baseURL + options.url, 
			method: options.method || 'GET', 
			data: options.data || {}, 
			header: {
			    'token':uni.getStorageSync('token') 
			},
			success: (res) => {
				uni.hideLoading()
				if (res.data.code !=1) {
					if(res.data.code==401){
						uni.redirectTo({
							url:'../user/login'
						})
					}
					return uni.showToast({
						title: res.data.msg,
						icon: 'none'
					})
				}
				resolve(res)
			},
			fail: (err) => {
				uni.hideLoading()
				reject(err)
			}
		})
	})
}